home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
bc_ti
/
ti651.asc
< prev
next >
Wrap
Text File
|
1992-02-24
|
1KB
|
67 lines
PRODUCT : C++ NUMBER : 651
VERSION : All
OS : PC DOS
DATE : February 25, 1992 PAGE : 1/1
TITLE : Initializing Static Class Members of Type Class
/* IMPORTANT! When testing static member initialization, you must
declare an instance of the class in a main function; otherwise, the
linker has no reference which it must try to resolve, and the
undefined symbol error will not be seen--thus you won't know that
your initialization was in error.
*/
//declare a class
class First {
public:
int count;
First() {} //must have callable constructor
};
//declare class containing static member of class First
class Second {
public:
static First fVar;
};
//initialize static member of class Second
First Second::fVar = First(); //initialize with explicit call to ctor
int main(void)
{
Second *sVarA = new Second;
delete sVarA;
return 0;
}